<template>
  <!-- 随机数公式Math.floor(Math.random()*(max-min+1))+min
  数组中最小索引值是0数组中
  最大索引值是数组总长度-1 -->
  <div>
    <ul>
      <li v-for="(item, index) in arr" :key="item">
        {{ item }}

        <button @click="del(index)">删除</button>
      </li>
    </ul>
    <button @click="btn">生成</button>
  </div>
</template>

<script>
export default {
  data() {
    return {
      arr:[1,11,10,101]
    };
  },
  methods: {
    btn() {
      this.arr.push(Math.floor(Math.random()*102)) 
  },
  del(index) {
    this.arr.splice(index,1)
  }
  }
};
</script>

<style>
</style>